package com.cskaoyan.market.service;

import com.cskaoyan.market.db.domain.MarketGoodsExample;
import com.cskaoyan.market.db.domain.MarketGoodsProductExample;
import com.cskaoyan.market.db.domain.MarketOrderExample;
import com.cskaoyan.market.db.domain.MarketUserExample;
import com.cskaoyan.market.db.mapper.MarketGoodsMapper;
import com.cskaoyan.market.db.mapper.MarketGoodsProductMapper;
import com.cskaoyan.market.db.mapper.MarketOrderMapper;
import com.cskaoyan.market.db.mapper.MarketUserMapper;
import com.cskaoyan.market.util.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: YaLiFeng
 * @description: TODO
 * @date: 2024/5/8 17:16
 */
public class AdminDashBoardServiceImpl implements AdminDashBoardService {
    @Override
    public Map<String,Integer> count() {
        SqlSession session= MybatisUtils.getSession();
        MarketUserMapper marketUserMapper=session.getMapper(MarketUserMapper.class);
        MarketGoodsMapper goodsMapper=session.getMapper(MarketGoodsMapper.class);
        MarketGoodsProductMapper marketGoodsProductMapper=session.getMapper(MarketGoodsProductMapper.class);
        MarketOrderMapper marketOrderMapper=session.getMapper(MarketOrderMapper.class);
        MarketUserExample marketUserExample=new MarketUserExample();
        MarketGoodsExample marketGoodsExample=new MarketGoodsExample();
        MarketGoodsProductExample marketGoodsProductExample=new MarketGoodsProductExample();
        MarketOrderExample marketOrderExample=new MarketOrderExample();
        Map<String,Integer> items=new HashMap<>();

        int userTotal= (int) marketUserMapper.countByExample(marketUserExample);
        int goodsTotal= (int) goodsMapper.countByExample(marketGoodsExample);
        int productTotal= (int) marketGoodsProductMapper.countByExample(marketGoodsProductExample);
        int orderTotal= (int) marketOrderMapper.countByExample(marketOrderExample);
        items.put("userTotal",userTotal);
        items.put("goodsTotal",goodsTotal);
        items.put("productTotal",productTotal);
        items.put("orderTotal",orderTotal);
        return items;
    }
}
